package com.carlinfo.shop.common.util;

import java.util.Date;

/**
 * 多线程测试
 * JDK1.4之前
 * @author wangshMac
 */
public class MyThread implements Runnable
{

	/**
	 * 一旦线程启动,就会执行一遍此方法
	 */
	@Override
	public void run()
	{
		System.out.println(Thread.currentThread().getName() + "=====" + new Date().toLocaleString());
	}
	
	public static void main(String[] args)
	{
		System.out.println("=======方法调用开始=====");
		new MyThread().run();
		System.out.println("=======方法调用结束=====");
		
		/* 多线程 
		 * 参数是runnable;传的是myThread;
		 * */
		System.out.println("=======线程开始=====");
		MyThread myThread = new MyThread() ;
		for(int i = 0 ; i <5 ; i ++)
		{
			Thread thread = new Thread(myThread);
			/* 线程启动 */
			thread.start();
		}
		System.out.println("=======线程结束=====");
	}
}
